<?php
/**
 * Created by PhpStorm.
 * User: liubao
 * Date: 2018/8/29
 * Time: 10:32
 */

namespace Qywx\Controller;


class IndexController extends BaseController
{
    public function index($action='/Qywx/Index/back')
    {
        if (isset($_SESSION['user'])) {
            $this->wxindex();
        } else {
            return BaseController::index($action);
        }
    }

    public function back()
    {
        $userInfo = BaseController::back();
        if (isset($userInfo)) {
            $name = $userInfo['name'];
            $user = M("db_user")->where("username='$name'")->find();
            if ($user){
                session('user', $user);
                //授权成功！
                $this->redirect('Index/wxindex');
            }else{
                $this->error('暂未匹配到登录人信息，请联系EHR人员');
            }

        } else {
            $this->error('授权失败');
        }
    }

    public function wxindex()
    {
        echo 123;
        die;
    }

}